package com.ecnu.sei.app.teacher;

import java.util.Set;

import com.ecnu.sei.app.course.ICourse;
import com.ecnu.sei.app.resources.Time;

// teacher who only proctors his/her own courses (e.g. ForeignTeacher, Official)

public class ProctorOwnCourseTeacher extends AbstractTeacher {
  public ProctorOwnCourseTeacher(String name, Set<Time> leaves) {
    super(name, leaves);
  }

  @Override
  public boolean isAvailableFor(ICourse course) {
    String teacherName = course.getCourseInfo().getTeacher().getName();
    if (!teacherName.equals(name)) {
      return false;
    }

    Time time = course.getCourseInfo().getExamInfo().getTime();
    if (time != null) {
      if (leaves.contains(time)) {
        return false;
      }

      if (timeTable.contains(time)) {
        return false;
      } else {
        for (Time other : timeTable) {
          if (time.isContHalfDay(other)) {
            return false;
          }
        }
      }
    } 

    return true;
  }
}
